<?php get_header(); ?>

	<main id="main" class="page-banco-de-imagens" role="main">
		<!-- section -->
		<section id="content">
			
			<h1><?php the_title(); ?></h1>
			
			<?php
			$count = 0;
			$wp_query = new WP_Query(array(
				'post_type'              => 'banco_de_imagem',
				'pagination'             => true,
				'paged'                  => (get_query_var('paged')) ? get_query_var('paged') : 1,
				'posts_per_page'         => '6'
			));
			if ($wp_query->have_posts()){
				while ($wp_query->have_posts()) : $wp_query->the_post();
				?>
					<article id="post-<?php the_ID(); ?>" <?php post_class($count%2 == 0 ? 'clr' : ''); ?>>
						<a href="#galeria" class="fboxtrigger"><?php echo get_image("capa_do_banco"); ?></a>
						<?php
						$galeria = get_field("imagem");
						$galeriaqnt = sizeof($galeria);
						?>
						<div class="fancyboximgs">
							<?php
							$args="zc=1&q=80&h=750&w=1000";
							foreach ($galeria as $key => $img) {
								$imgTam = array("w" => 1000, "h" => 750, "zc" => 1, "q" => 80);
   								// $imgAtt = array("class" => "fancybox", "rel" => "banco");
							?>
							<a href="<?php echo get_image("imagem", 1, $key, 0, NULL, $imgTam ); ?>" class="fancybox" rel="banco<?php echo get_the_ID();?>">Imagem <?php echo $key; ?></a>
							<?php } ?>
						</div>
						<h2 class="t2"><?php /*<a href="<?php the_permalink(); ?>">*/?><?php the_title(); ?><?php /*</a>*/?></h2>
						<strong><?php echo $galeriaqnt > 0 ?  ($galeriaqnt > 1 ? $galeriaqnt." imagens" : $galeriaqnt." imagem") : ""; ?></strong>
						<br class="clear">
					</article>
					<!-- /article -->
				<?php $count++;
				endwhile;
				html5wp_pagination($wp_query->max_num_pages);
			}else{
			?>
				<!-- article -->
				<article>
					<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
				</article>
				<!-- /article -->
			<?php
			}
			wp_reset_postdata();
			?>
		
		</section>
		<!-- /section -->
		<?php get_sidebar(); ?>
	</main>
	<script>
		$(document).ready(function() {
			js.banco_de_imagens();
		});
	</script>
<?php get_footer(); ?>
